<?php


/* --------------------------
 * PREPROCESS THEME HOOKS
 * -------------------------- */

function walesyoung_preprocess_html(&$variables){
    // Add Stylesheet
    drupal_add_css('_ui/libs/css/reset.css', array('group' => CSS_THEME, 'preprocess' => FALSE));
    drupal_add_css('_ui/skin/css/style.css', array('group' => CSS_THEME, 'preprocess' => FALSE));
    drupal_add_css('_ui/skin/css/shared.css', array('group' => CSS_THEME, 'preprocess' => FALSE));


    // Add Javascript
    drupal_add_js('_ui/libs/jquery/js/reset.js', array('group' => JS_THEME, 'preprocess' => FALSE));
    drupal_add_js('_ui/skin/js/_main.js', array('group' => JS_THEME, 'preprocess' => FALSE));
}


/* --------------------------
 * UTILITIES
 * -------------------------- */

/* Format markup for primary menu */
function walesyoung_main_menu($main_menu) {
    $menu_tree = menu_tree_all_data('main-menu');
    $menu_output = menu_tree_output($menu_tree);
    $output = drupal_render($menu_output);

    return $output;
}

function ellipsis($text, $max=100, $append='&hellip;') {
    if (strlen($text) <= $max) {
        return $text;
    }

    $out = substr($text,0,$max);
    if (strpos($text,' ') === FALSE) {
        return $out.$append;
    }

    return preg_replace('/\w+$/','',$out).$append;
}



// Now include the Garland phptemplate_* functions
// Make sure this line comes AFTER any function definitions in this file
require_once $_SERVER['DOCUMENT_ROOT'].'/themes/garland/template.php';
